/**
 * 代理中的 this
 */
;(function () {
    const target = {
        thisValEquealsProxy() {
            return this === proxy
        }
    }

    const proxy = new Proxy(target, {})
    console.log(target.thisValEquealsProxy())
    console.log(proxy.thisValEquealsProxy())
})()

;(function () {
    const wm = new WeakMap();

    class User {
        constructor(userId) {
            wm.set(this, userId);
        }

        set id(userId) {
            wm.set(this, userId);
        }

        get id() {
            return wm.get(this);
        }
    }

    const user = new User(123)
    console.log(user.id)
    const userInstanceProxy = new Proxy(user, {});
    console.log(userInstanceProxy.id); // undefined

    const UserClassProxy = new Proxy(User,{})
    const proxyUser=new UserClassProxy(456)
    console.log(proxyUser.id)
    console.log(typeof UserClassProxy)
})()